/**
 * Handle focus element gaining focus.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean} proceed to next on-focus-gained handler
 *
 * @properties={typeid:24,uuid:"376A3D9D-319D-4D02-820C-F58E86F156AC"}
 */
function onFocusGained_id_tributaria(event) 
{
	if ((extranjero == 0) || (extranjero == null))
	{
		globals.DIALOGS.showQuestionDialog('Detalle de proveedores', 'Debe ingresar primero si es extranjero' ,  "Ok")
		elements.extranjero.requestFocus(true)
	}
	return true
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"9A13BAEE-4F3A-41E2-A7C3-34873AFA6825"}
 */
function onDataChangeCuit(oldValue, newValue, event) {
	var query 	= 'select proveedor_id,razon_social from proveedor where cuit = ? and es_fletero = ?'
	var args 	= [newValue, es_fletero]
	var max 	= 1
	
	var $ds 	= databaseManager.getDataSetByQuery('infocom',query,args,max)
	
	if ($ds.getMaxRowIndex() != 0)
	{
		globals.DIALOGS.showErrorDialog('Error',  'CUIT Duplicado: ' + $ds.getValue(1,2),  "OK")
		return false
	}
	return true
}
